<?php if (isset($success_message)) : ?>
<div class="noty_bar noty_theme_default noty_layout_topCenter noty_success" id="noty_success_1355937644582" style="cursor: pointer; left: 559.5px; display: block;">
    <div class="noty_message"><span class="noty_text">Guia creada con exito!</span></div>
</div>
<?php endif; ?>
<div class="noty_bar noty_theme_default noty_layout_topCenter noty_error hidden" id="message_error_formAddPurchase" style="cursor: pointer; left: 559.5px">
    <div class="noty_message"><span id="contentMessageErrorFormAddPurchase" class="noty_text"></span></div>
</div>
<div class="grid_container">
    <form id="formAddPurchase" action="submit" method="post" class="form_container">
	<div class="grid_12">
		<div class="widget_wrap">
			<div class="widget_top">
                                            <span class="h_icon magnifying_glass"></span>
                                            <h6>
                                            <?php if(isset($parametro)== 1){ echo 'Nueva Guía de Venta'; ?>
                                                <a class="action-icons c-view" href="<?php echo base_url(); ?>index.php/sales/search" original-title="Nuevo">Buscar</a>
                                            <?php }else{ echo 'Buscar Guía de Venta';  ?>
                                                <a class="action-icons c-add" href="<?php echo base_url(); ?>index.php/sales/add" original-title="Nuevo">Nuevo</a>
                                            <?php } ?>
                                            </h6>
			</div>
                    
			<div class="widget_content">
				<ul>
					<li>
						<div class="form_grid_12">
							<div class="form_input">
							    <div class=" form_grid_4 alpha">
									<span class="label_head" for="type_document">Tipo de Documento</span>
									<?php 
									    $options = array();
									    foreach ($typeDocuments as $td) {
                                            $options[$td->id] = $td->description;
                                        }
                                        $extra = 'id="type_document" tabindex="1" style="width:300px; height:25px" class="chzn-select full"';
    									echo form_dropdown('tipo', $options, '3', $extra);
									?>
								</div>
								<div class=" form_grid_4 alpha">
									<span class="label_head">N° Documento</span>
									<?php
                                    $data = array(
                                        'name'        => 'numero',
                                        'id'          => 'numero',
                                        'class'       => 'noEmpty',
                                        'value'       => @field($articulo->numero, set_value('numero')),
                                        'tabindex'    => '2'
                                    );
                                    echo form_input($data);
                                    ?>
								</div>
								<div class=" form_grid_2">
									<span class="label_head">Fecha</span>
									<?php
                                    $data = array(
                                        'name'        => 'date',
                                        'id'          => 'numero',
                                        'value'       => @field(set_value('date'), date('d/m/Y')),
                                        'tabindex'    => '2'
                                    );
                                    echo form_input($data);
                                    ?>
								</div>
								<span class="clear"></span>
							</div>
						</div>
					</li>
					<li>
					<div class="form_grid_12">
						<div class="form_input">
							<div class="form_grid_5 alpha">
								<span class="label_head">Cliente</span>
								<?php 
								    $options = array();
								    $options[-1] = "";
								    foreach ($clients as $td) {
                                        $options[$td->id] = $td->name;
                                    }
                                    $extra = 'id="client" tabindex="3" style="width:350px" class="chzn-select full" data-placeholder="Elegir..."';
									echo form_dropdown('client', $options, '', $extra);
								?>
                                                                        <?php if (!isset($parametro) == 1) : ?>
									<a href="#" class="basic-modal">Nuevo</a>
                                                                        <?php endif; ?>
								</div>
								<div id="divRuc" class="form_grid_3" style="display: none">
									<span class="label_head">RUC</span>
									<?php
                                    $data = array(
                                        'id'          => 'client_ruc',
                                        'name'          => 'client_ruc',
                                        'tabindex'    => '3',
                                        'class'       => '',
                                        'readonly'    =>'readonly'
                                    );
                                    echo form_input($data);
                                    ?>
								</div>
								<!-- div class="form_grid_4">
									<span class="label_head">Dirección</span>
									<?php
                                    $data = array(
                                        'id'          => 'client_address',
                                        'name'          => 'client_address',
                                        'tabindex'    => '4',
                                        'class'       => '',
                                        'readonly'    =>'readonly'
                                    );
                                    echo form_input($data);
                                    ?>
								</div-->
								<span class="clear"></span>
							</div>
						</div>
						</li>
						<li>
						<div class="form_grid_12">
							<div class="form_input">
								<div class="form_grid_12 alpha">
									<span class="label_head">Observaciones</span>
									<?php
                                    $data = array(
                                        'name'        => 'observations',
                                        'id'          => 'observations',
                                        'tabindex'    => '5',
                                    );
                                    echo form_input($data);
                                    ?>
								</div>
								<span class="clear"></span>
							</div>
						</div>
						</li>
					</ul>
                                        <?php if (!isset($parametro) == 1) : ?>
					<div class="form_grid_2 " style="margin-bottom: 10px; float: right">
						<button id="addProduct" class="btn_small btn_blue"><span>Agregar Producto</span></button>
					</div>
                                        <?php endif; ?>
                                        <?php if (!isset($parametro) != 1) : ?>
					<div class="form_grid_2 " style="margin-bottom: 10px; float: right">
						<button class="btn_small btn_blue"><span>Buscar </span></button>
					</div>
                                        <?php endif; ?>
					<table class="wtbl_list">
    					<thead>
        					<tr>
        						<th width="10%">Código</th>
        						<th width="30%">Descripción</th>
        						<th width="10%">Cajas</th>
        						<th width="10%">Empaques</th>
        						<th width="10%">Unidades</th>
        						<th width="20%">Unidad</th>
        						<th width="20%">Precio</th>
        						<th width="10%"></th>
        					</tr>
    					</thead>
    					<tbody id="contentProductList">
    					</tbody>
					</table>
				</div>
			</div>
			<br />
                        <?php if (!isset($parametro) == 1) : ?>
			<button type="submit" class="btn_small btn_orange"><span>Guardar</span></button>
                        <?php endif; ?>
		</div>
	</form>
	<span class="clear"></span>
	<div id="basic-modal-content">
		<h3>Nuevo Cliente</h3>
			<form id="formAddClient" action="<?php echo site_url("clients/add"); ?>" method="post" class="form_container left_label">
			<ul>
				<li>
					<div class="form_grid_12">
						<label class="field_title" for="rs">Razón Social <span class="req">*</span></label>
						<div class="form_input">
						<?php
                        $data = array(
                            'name'        => 'name',
                            'id'          => 'name',
                            'value'       => @field($client->name, set_value('name')),
                            'class'       => 'noEmpty',
                            'tabindex'    => '20'
                        );
                        echo form_input($data);
                        ?>
						</div>
					</div>
				</li>
				<li>
					<div class="form_grid_12">
						<label class="field_title" for="ruc">RUC</label>
						<div class="form_input">
						<?php
                        $data = array(
                            'name'        => 'ruc',
                            'id'          => 'ruc',
                            'maxlength'   => 11,
                            'value'       => @field($client->ruc, set_value('ruc')),
                            'tabindex'    => '21'
                        );
                        echo form_input($data);
                        ?>
						</div>
					</div>
				</li>
				<li>
					<div class="form_grid_12">
						<label class="field_title">Dirección</label>
						<div class="form_input">
						<?php
                        $data = array(
                            'name'        => 'address',
                            'id'          => 'address',
                            'value'       => @field($client->address, set_value('address')),
                            'tabindex'    => '22'
                        );
                        echo form_input($data);
                        ?>
						</div>
					</div>
				</li>
				<li>
					<div class="form_grid_12">
						<label class="field_title">Teléfono</label>
						<div class="form_input">
						<?php
                        $data = array(
                            'name'        => 'telephone',
                            'id'          => 'telephone',
                            'class'       => 'onlyNumber',
                            'onkeypress'  => 'return isNumberKey(event)',
                            'value'       => @field($client->phone, set_value('phone')),
                            'tabindex'    => '23'
                        );
                        echo form_input($data);
                        ?>
						</div>
					</div>
				</li>
				<li>
					<div class="form_grid_12">
						<label class="field_title">E-mail</label>
						<div class="form_input">
						<?php
                        $data = array(
                            'name'        => 'email',
                            'id'          => 'email',
                            'class'       => 'email',
                            'value'       => @field($client->email, set_value('email')),
                            'tabindex'    => '24'
                        );
                        echo form_input($data);
                        ?>
						</div>
					</div>
				</li>
				<li>
					<div class="form_grid_12">
						<button type="submit" class="btn_small btn_orange"><span>Guardar</span></button>
					</div>
				</li>
			</ul>
		</form>
	</div>
	<div id="add-product-model">
	</div>
</div>
<table id="listProductBlank" class="clear">
    <tr id="rowListProductBlank" class="tr_even">
		<td class="elementList codeProduct"></td>
		<td class="elementList descriptionProduct">producto 11</td>
		<td class="elementList quantityBoxesProduct">10</td>
		<td class="elementList quantityPackagesProduct">10</td>
		<td class="elementList quantityUnitsProduct">10</td>
		<td class="elementList unitProduct">unidades</td>
		<td class="elementList priceProduct">S/12.00</td>
		<td class="elementList inputProduct"><a href="#" class="action-icons c-Delete delProductList" original-title="Borrar">Delete</a></td>
	</tr>
</table>